import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: '/admin'
  },

  {
    path: '/admin',
    name: 'Admin',
    component: () => import( /* webpackChunkName: "admin" */ '../layout/Admin.vue'),
    redirect: '/admin/welcome',
    children: [{
        path: 'welcome',
        name: 'Welcome',
        component: () => import( /* webpackChunkName: "welcome"" */ '../views/admin/Home.vue'),
      },
      {
        path: 'user',
        name: 'User',
        component: () => import( /* webpackChunkName: "user" */ '../views/admin/user/List.vue'),
      },
      {
        path: 'user/add',
        name: 'User',
        component: () => import( /* webpackChunkName: "useradd" */ '../views/admin/user/Add.vue'),
      },
      {
        path: 'user/:id',
        name: 'User',
        component: () => import( /* webpackChunkName: "user" */ '../views/admin/user/Detail.vue'),
      },

      {
        path: 'product',
        name: 'Product',
        component: () => import( /* webpackChunkName: "product" */ '../views/admin/product/List.vue'),
      },
      {
        path: 'product/:id',
        name: 'Product',
        component: () => import( /* webpackChunkName: "product" */ '../views/admin/product/Detail.vue'),
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import( /* webpackChunkName: "login" */ '../views/Login.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router